package com.patrol.logisticsmanage.ui.base;

import android.app.Activity;
import android.graphics.Rect;

import com.patrol.logisticsmanage.ui.appear.ImageInfo;
import com.previewlibrary.GPreviewBuilder;
import com.previewlibrary.enitity.IThumbViewInfo;

import java.util.ArrayList;
import java.util.List;

public class ImagePreviewUtils {
    public static void goToPreview(List<ImageInfo> imageInfos,int currentPosition, Activity activity){
        //组织数据
        ArrayList<UserViewInfo> mThumbViewInfoList = new ArrayList<>(); // 这个最好定义成成员变量
        UserViewInfo item;
        mThumbViewInfoList.clear();
        for (int i = 0;i < imageInfos.size(); i++) {
            Rect bounds = new Rect();
            //new ThumbViewInfo(图片地址);
            item=new UserViewInfo(imageInfos.get(i).getImageUrl());
            item.setBounds(bounds);
            mThumbViewInfoList.add(item);
        }

//打开预览界面
        GPreviewBuilder.from(activity)
                //是否使用自定义预览界面，当然8.0之后因为配置问题，必须要使用
//                .to(ImageLookActivity.class)
                .setData(mThumbViewInfoList)
                .setCurrentIndex(currentPosition)
                .setSingleFling(true)
                .setType(GPreviewBuilder.IndicatorType.Number)
                // 小圆点
//  .setType(GPreviewBuilder.IndicatorType.Dot)
                .start();//启动

    }
}
